package com.lzh.persevere.controller;

import com.lzh.persevere.common.R;
import com.lzh.persevere.common.ResultUtil;
import com.lzh.persevere.model.qo.essay.EssayPageQO;
import com.lzh.persevere.model.ro.essay.SendEssayRO;
import com.lzh.persevere.model.vo.essay.EssayVO;
import com.lzh.persevere.service.EssayInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

/**
 * 随笔controller
 *
 * @author luzhiheng
 * @since 2025-07-26
 */
@Api(tags = "随笔")
@RestController
@RequestMapping("/essay")
public class EssayInfoController {

    @Resource
    private EssayInfoService essayInfoService;

    @ApiOperation(value = "分页查询随笔")
    @PostMapping("/findEssayPage")
    public R<Map<String, Object>> findEssayPage(@Valid @RequestBody EssayPageQO qo) {
        return ResultUtil.success(essayInfoService.pageList(qo));
    }

    @ApiOperation(value = "发送随笔")
    @PostMapping("/sendEssay")
    public R<EssayVO> sendEssay(@Valid @RequestBody SendEssayRO ro) {
        return ResultUtil.success(essayInfoService.sendEssay(ro));
    }
}
